package 尚硅谷;

import java.util.concurrent.CountDownLatch;

/**
 * @author zhangmin
 * @create 2022-03-23 20:44
 */
public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {

    }

    public static void closeDoor(){
        CountDownLatch countDownLatch=new CountDownLatch(6);
        for (int i = 0; i < 6; i++) {
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+"\t 上晚自习，离开教室");
                countDownLatch.countDown();
            },String.valueOf(i)).start();
        }
        try {
            countDownLatch.wait();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+"\t 最后关门");
    }
}
